<!DOCTYPE html>

<html class="no-js">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title></title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="https://cdn.staticfile.org/axios/0.19.0-beta.1/axios.js"></script>
    <script src="https://cdn.staticfile.org/vue/2.5.17/vue.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.13.0/theme-chalk/index.css" />
    <script src="https://cdn.staticfile.org/element-ui/2.13.0/index.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/animate.css/3.7.0/animate.min.css" />
    <link rel="stylesheet" href="../../../lib/index.css" />
    <script src="../../../lib/cvue.js"></script>
    <style>
        .demo-affix {
            display: inline-block;
            color: #fff;
            padding: 10px 30px;
            text-align: center;
            background: rgba(0, 153, 229, .9);
        }

        .demo-block {
            height: 2000px;
        }

        .demo-line {
            height: 100px;
        }

        #haha {
            position: absolute;
            right: 200px;
            top: 300px;
            width: 600px;
            height: 800px;
            border: 1px solid red;
        }
    </style>
</head>

<body>
    <div id="app">
        <cvue-affix>
            <span class="demo-affix">固定在最顶部</span>
        </cvue-affix>
        <div class="demo-line"></div>
        <div id="haha">
            <cvue-affix :offset-top="50" id="haha">
                <span class="demo-affix">固定在距离顶部 50px 的位置</span>
            </cvue-affix>
        </div>
        <div class="demo-line"></div>
        <cvue-affix :offset-top="100">
            <span class="demo-affix">固定在距离顶部 100px 的位置</span>
        </cvue-affix>
        <div class="demo-line"></div>
        <cvue-affix :offset-bottom="150" @on-change="change">
            <span class="demo-affix">固定在距离底部 150px 的位置</span>
        </cvue-affix>
        <div class="demo-block"></div>
    </div>
</body>
<script>
    new Vue({
        el: '#app',
        methods: {
            change(e) {
                console.log('hello', e);
            }
        }
    })
</script>

</html>